home *** CD-ROM | disk | FTP | other *** search
- /*
- * the class STAGE and KBAN_FUNCTION
- * Copyright (C) 1996, 1997 Kazutaka Hirata <khirata@jove.acs.unt.edu>
- */
-
- #include "stdafx.h"
-
- #include "kbanfunc.h"
-
- STAGE* STAGE::init(KBAN_INFO& info, KBAN_DRAW& draw)
- { return this; }
-
- STAGE* STAGE::pre_redraw(KBAN_INFO& info, KBAN_DRAW& draw)
- { return this; }
-
- STAGE* STAGE::redraw(KBAN_INFO& info, KBAN_DRAW& draw)
- { return this; }
-
- STAGE* STAGE::shift_up(KBAN_INFO& info, KBAN_DRAW& draw)
- { return this; }
-
- STAGE* STAGE::shift_down(KBAN_INFO& info, KBAN_DRAW& draw)
- { return this; }
-
- STAGE* STAGE::control_up(KBAN_INFO& info, KBAN_DRAW& draw)
- { return this; }
-
- STAGE* STAGE::control_down(KBAN_INFO& info, KBAN_DRAW& draw)
- { return this; }
-
- STAGE* STAGE::key_in(KBAN_INFO& info, KBAN_DRAW& draw, UINT key, UINT nFlags)
- { return this; }
-
- STAGE* STAGE::mouse_out (KBAN_INFO& info, KBAN_DRAW& draw)
- { return this; }
-
- STAGE* STAGE::mouse_move(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
- { return this; }
-
- STAGE* STAGE::mouse_left_up(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
- { return this; }
-
- STAGE* STAGE::mouse_left_down(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
- { return this; }
-
- STAGE* STAGE::mouse_right_up(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
- { return this; }
-
- STAGE* STAGE::mouse_right_down(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
- { return this; }
-
- STAGE* STAGE::user_message(KBAN_INFO& info, KBAN_DRAW& draw, uint wval, long lval)
- { return this; }
-
- void STAGE::end(KBAN_INFO& info, KBAN_DRAW& draw)
- { }
-
- int KBAN_FUNCTION::decide_next_stage(KBAN_INFO& info, KBAN_DRAW& draw, STAGE* result)
- {
- while(result != m_current_stage) {
- m_current_stage->end(info, draw);
- delete m_current_stage;
- m_current_stage = result;
- if(m_current_stage != NULL) {
- result = m_current_stage->init(info, draw);
- }
- if(result == NULL) {
- m_current_stage = NULL;
- break;
- }
- }
- return (m_current_stage != NULL) ? TRUE : FALSE;
- }
-
- int KBAN_FUNCTION::init(KBAN_INFO& info, KBAN_DRAW& draw)
- {
- m_current_stage = init_new(info, draw);
- STAGE* result = m_current_stage->init(info, draw);
- if(result != m_current_stage) {
- decide_next_stage(info, draw, result);
- }
- return (m_current_stage != NULL) ? MENU_CONTINUE : MENU_END;
- }
-
- const char* KBAN_FUNCTION::get_name(void)
- { return NULL; }
-
- STAGE* KBAN_FUNCTION::init_new(KBAN_INFO& info, KBAN_DRAW& draw)
- { return NULL; }
-
- void KBAN_FUNCTION::end(KBAN_INFO& info, KBAN_DRAW& draw)
- {
- if(m_current_stage != NULL) {
- m_current_stage->end(info, draw);
- delete m_current_stage;
- m_current_stage = NULL;
- }
- }
-
- #define EVENT_FUNCTION(x) \
- int ret = TRUE; \
- if(m_current_stage != NULL) { \
- STAGE* result = x; \
- ret = decide_next_stage(info, draw, result); \
- } \
- return ret;
-
- int KBAN_FUNCTION::pre_redraw(KBAN_INFO& info, KBAN_DRAW& draw)
- { EVENT_FUNCTION(m_current_stage->pre_redraw(info, draw)); }
-
- int KBAN_FUNCTION::redraw(KBAN_INFO& info, KBAN_DRAW& draw)
- { EVENT_FUNCTION(m_current_stage->redraw(info, draw)); }
-
- int KBAN_FUNCTION::shift_up(KBAN_INFO& info, KBAN_DRAW& draw)
- { EVENT_FUNCTION(m_current_stage->shift_up(info, draw)); }
-
- int KBAN_FUNCTION::shift_down(KBAN_INFO& info, KBAN_DRAW& draw)
- { EVENT_FUNCTION(m_current_stage->shift_down(info, draw)); }
-
- int KBAN_FUNCTION::control_up(KBAN_INFO& info, KBAN_DRAW& draw)
- { EVENT_FUNCTION(m_current_stage->control_up(info, draw)); }
-
- int KBAN_FUNCTION::control_down(KBAN_INFO& info, KBAN_DRAW& draw)
- { EVENT_FUNCTION(m_current_stage->control_down(info, draw)); }
-
- int KBAN_FUNCTION::key_in(KBAN_INFO& info, KBAN_DRAW& draw, UINT key, UINT nFlags)
- { EVENT_FUNCTION(m_current_stage->key_in(info, draw, key, nFlags)); }
-
- int KBAN_FUNCTION::mouse_out(KBAN_INFO& info, KBAN_DRAW& draw)
- { EVENT_FUNCTION(m_current_stage->mouse_out(info, draw)); }
-
- int KBAN_FUNCTION::mouse_move(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
- { EVENT_FUNCTION(m_current_stage->mouse_move(info, draw, pc, nFlags)); }
-
- int KBAN_FUNCTION::mouse_left_up(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
- { EVENT_FUNCTION(m_current_stage->mouse_left_up(info, draw, pc, nFlags)); }
-
- int KBAN_FUNCTION::mouse_left_down(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
- { EVENT_FUNCTION(m_current_stage->mouse_left_down(info, draw, pc, nFlags)); }
-
- int KBAN_FUNCTION::mouse_right_up(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
- { EVENT_FUNCTION(m_current_stage->mouse_right_up(info, draw, pc, nFlags)); }
-
- int KBAN_FUNCTION::mouse_right_down(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
- { EVENT_FUNCTION(m_current_stage->mouse_right_down(info, draw, pc, nFlags)); }
-
- int KBAN_FUNCTION::user_message(KBAN_INFO& info, KBAN_DRAW& draw, uint wval, long lval)
- { EVENT_FUNCTION(m_current_stage->user_message(info, draw, wval, lval)); }
-